package src.Packets;

import src.Util.Stream;
import src.Players.*;
import src.Main;
import src.Skills.Woodcutting;
import src.Games.CastleWars;

public class ObjectClick1
{

    public Player p;

    /*
    * make sure to document EVERY coordinate to go with each object.
    * This will prevent people from spawning an object client side and actually using it.
    * So make sure to include with the id, objectX == # && objectY == #
    */

    public ObjectClick1(Player p)
    {
        if(p == null || p.inStream == null)
        {
            return;
        }
        if(!p.objectClick1)
        {
            p.clickX = p.inStream.readSignedWordBigEndianA();
            p.clickId = p.inStream.readUnsignedWord(); 
            p.clickY = p.inStream.readUnsignedWordA();
            p.objectClick1 = true;
        }
        if(Main.m.ge.getDistance(p.clickX, p.clickY, p.absX, p.absY) > 1)
        {
            return;
        }
	PlayerChecks pc = new PlayerChecks(p);
	PlayerWeapon pw = new PlayerWeapon(p);
	CastleWars cw = new CastleWars();
        p.objectClick1 = false;
        switch(p.clickId)
        {
	    case 2213:   
	    case 2214:
	    case 3045:
	    case 5276:
	    case 6084:
	   	p.frame.showInterface(p, 5292, 5063);
                p.frame.resetItems(p, 5064);
                p.frame.resetBank(p);
	    break; 

	    case 1557: // 4387
		cw.addPlayerSara(p);
	    break;

	    case 1558: // 4388
		cw.addPlayerZammy(p);
	    break;

	    case 1276:
	    case 1277:
	    case 1278:
	    case 1279:
	    case 1280:
	    case 1282:
	    case 1283:
	    case 1284:
	    case 1285:
	    case 1286:
	    case 1287:
	    case 1288:
	    case 1289:
	    case 1290:
	    case 1291:
	    case 1333:
	    case 1365:
	    case 1384:
	    case 1281:
	    case 2020:
	    case 5902:
	    case 5903:
	    case 5904:
 	    case 2023:
	    case 1308:
	    case 5551:
	    case 5552:
	    case 5553:
	    case 9036:
	    case 1307:
	    case 9034:
	    case 1306:
		while(pc.fullPlayerInv(p)) {
			Woodcutting w = new Woodcutting(p);
			w.cutTree(p.clickId);
			w = null;
		}
	    break;

            default:
                Main.m.log("[" + p.playerIndex + "-" + p.username + "] Object1 click " + p.clickId + ", x = " + p.clickX + ", y = " + p.clickY);
            break;
        }
    }
}